package com.github.exceptions;

/**
 * <p>assert util</p>
 *
 * @author  Crab2Died
 */
public abstract class Assert {

    /**
     * <p>assert the java object is not null
     * ,otherwise throw the exception</p>
     *
     * @param obj object
     * @param msg description
     * @author  Crab2Died
     */
    static public void notNull(Object obj, String msg) {

        if (null == obj)
            throw new IllegalArgumentException(msg);
    }

    /**
     * <p>assert the java object is not null
     * ,otherwise throw the exception</p>
     *
     * @param obj object
     * @author  Crab2Died
     */
    static public void notNull(Object obj) {

        notNull(obj, "this argument must not be null");
    }

    /**
     * <p>assert the java object is null
     * ,when not throw the exception</p>
     *
     * @param obj object
     * @param msg description
     * @author  Crab2Died
     */
    static public void isNull(Object obj, String msg) {

        if (null != obj)
            throw new IllegalArgumentException(msg);
    }

    /**
     * <p>assert the java object is null
     * ,otherwise throw the exception</p>
     *
     * @param obj object
     * @author  Crab2Died
     */
    static public void isNull(Object obj) {

        isNull(obj, "this argument must not null");
    }

}
